import numpy as np
import matplotlib.pyplot as plt

print('------第一题-------')
def amusitelang(n):
    for i in range(10**(n-1),10**n,1):
        sum=0
        a=i
        while a>0:
            sum+=(a%10)**n
            a//=10
        if i==sum:
            print(i)
amusitelang(3)

print('------第二题-------')
class stack():
    def __init__(self,size):
        self.stack=[]
        self.size=size
    def push(self,item):
        self.stack.append(item)
    def pop(self):
        if len(self.stack)==0:
            print('空栈')
            return False
        else:
            self.top = self.top - 1
            self.stack.pop()
            return True
    def top(self):
        if len(self.stack)!=0:
            return self.stack[self.top]
    def isEmpty(self):
        if len(self.stack)==0:
            return Ture
    def length(self):
        return self.stack.len()
    def iterate(self):
        if len(self.stack)==0:
            print('为空栈')
        else:
            for i in self.stack:
                print(i)
s=stack(10)
for i in range(10):
    s.push(i)
s.iterate()



print('------第三题-------')
print('3.1')
x1=np.empty([4,6],dtype=int)
print(x1)
x2=np.ones([1,6])
print(x2)
print('3.2')
x3=x1+x2
print(x3)
print('3.3')
x4 = np.asarray(x1+x2).reshape([3,8])
print(x4)
print(3.4)
print(np.sort(x4,axis=0))

print('------第四题-------')
xpoints = np.array([0,6])
ypoints = np.array([0, 100])

xps = np.arange(1,7)
yps = np.random.randint(1,51,size = 6)

plt.subplot(1,2,1)
plt.title("图1")
plt.plot(xps,yps,marker='*')
plt.xlabel("随机数")
plt.ylabel("折线图")
plt.subplot(1,2,2)
plt.title("图2")
plt.scatter(xps,yps,marker='o')
plt.xlabel("随机数")
plt.ylabel("散点图")
plt.suptitle("作业")
plt.show()





